﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;

namespace Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.Focus();
        }
        [DllImport("kernel32")]
        public static extern bool Beep(int freq, int duration);

        private void button1_Click(object sender, EventArgs e)
        {
            Beep((int)numericUpDown1.Value, (int)numericUpDown2.Value);
            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(260);
            }
            catch { }
        }

        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Beep((int)e.Argument, 300);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(261);
            }
            catch { }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(293);
            }
            catch { }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(329);
            }
            catch { }
        }

        private void button7_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(349);
            }
            catch { }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(392);
            }
            catch { }

        }

        private void button8_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(440);
            }
            catch { }

        }

        private void Form1_KeyDown(object sender, KeyEventArgs e)
        {
            
            switch (e.KeyCode)
            {
                case Keys.A:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(260);
                    }
                    catch { }
                    break;
                case Keys.S:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(300);
                    }
                    catch { }
                    break;
                case Keys.D:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(340);
                    }
                    catch { }
                    break;
                case Keys.F:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(380);
                    }
                    catch { }
                    break;
                case Keys.G:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(420);
                    }
                    catch { }
                    break;
                case Keys.H:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(460);
                    }
                    catch { }
                    break;
                case Keys.J:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(500);
                    }
                    catch { }
                    break;
                case Keys.K:
                    try
                    {
                        backgroundWorker1.RunWorkerAsync(540);
                    }
                    catch { }
                    break;
                default:
                    break;
            }
        }

        private void button9_Click(object sender, EventArgs e)
        {
            try
            {
                backgroundWorker1.RunWorkerAsync(490);
            }
            catch { }
        }

        private void button9_KeyDown(object sender, KeyEventArgs e)
        {

        }

        private void button10_Click(object sender, EventArgs e)
        {
           
            List<string> element = new List<string>();

        }
    }
}
